from openpyxl import Workbook

# 创建一个新的工作簿对象
wb = Workbook()

# 激活 worksheet
ws = wb.active

# 给单元格赋值
ws['A1'] = "Hello"
ws['B1'] = "World"

# 另一种给单元格赋值的方法
ws.cell(row=2, column=1, value="Goodbye")
ws.cell(row=2, column=2, value="Cruel World")

# 保存文档
wb.save("sample.xlsx")